class CServerConnection;
class CGameWorld;
class CInputManager;

enum EMouseButtonID;
enum EKeyboardButtonID;
enum EKeyboardModifier;

enum EUserAction
{
    eUserAction_SetSpeed0,
    eUserAction_SetSpeed1,
    eUserAction_SetSpeed2,
    eUserAction_SetSpeed3,
    eUserAction_SetSpeed4,
    eUserAction_SetSpeed5,
    eUserAction_SetSpeed6,
    eUserAction_SetSpeed7,
    eUserAction_SetSpeed8,
    eUserAction_SetSpeed9,
    eUserAction_SetSpeed10,
    eUserAction_SetSpeed11,
    eUserAction_SetSpeed12,
    eUserAction_SetSpeedHalfMax,
    eUserAction_SetSpeedMax,
    eUserAction_DecreaseSpeed,
    eUserAction_IncreaseSpeed,
    eUserAction_SetCourse,
    eUserAction_Orbit,
    eUserAction_LockOn,
    eUserAction_Transwarp,
    eUserAction_FirePhaser,
    eUserAction_FirePhoton,
    eUserAction_FirePlasma,
    eUserAction_DetEnemyTorps,
    eUserAction_DetMyTorps,
    eUserAction_ToggleShields,
    eUserAction_ToggleTractor,
    eUserAction_TogglePressor,
    eUserAction_ToggleCloak,
    eUserAction_EnterRepairMode,
    eUserAction_ToggleDockingPermission,
    eUserAction_BombPlanet,
    eUserAction_BeamUpArmies,
    eUserAction_BeamDownArmies,
    eUserAction_PracticeRobot,
    eUserAction_GetPlanetDetail,
};

class CUserInputMouseHitData
{
public:
    CUserInputMouseHitData(DWORD dwXLocation, DWORD dwYLocation, BYTE bAngle) : m_fHasData(true), m_dwXLocation(dwXLocation), m_dwYLocation(dwYLocation), m_bAngle(bAngle) { }
    CUserInputMouseHitData() : m_fHasData(false) { }

    bool IsDataAvailable() const { return m_fHasData; }
    DWORD GetXLocation() const { return m_dwXLocation; }
    DWORD GetYLocation() const { return m_dwYLocation; }
    BYTE  GetAngle() const { return m_bAngle; }

private:
    bool m_fHasData;
    DWORD m_dwXLocation;
    DWORD m_dwYLocation;
    BYTE m_bAngle;
};



class CUserInput
{
public:
    CUserInput(CServerConnection* pServerConnection, CGameWorld* pGameWorld, CInputManager* pInputManager);

    void MousePressed(EMouseButtonID eMouseButtonID, const CUserInputMouseHitData& mouseHitData);
    void KeyPressed(EKeyboardButtonID eKeyboardButtonID, const CUserInputMouseHitData& mouseHitData);    

private:

    bool IsModifierActive(EKeyboardModifier);
    void ExecuteAction(EUserAction eUserAction, const CUserInputMouseHitData& mouseHitData);
    void ExecuteSpeedAction(char chNewSpeed);

    DWORD GetMaxShipSpeed();
    DWORD GetCurrentShipSpeed();
    DWORD GetPlayerIDNearPosition(DWORD dwXLocation, DWORD dwYLocation);
    bool IsPlayerNearPosition(DWORD dwXLocation, DWORD dwYLocation);

    DWORD GetPlanetIDNearPosition(DWORD dwXLocation, DWORD dwYLocation);
    bool IsPlanetNearPosition(DWORD dwXLocation, DWORD dwYLocation);

    DWORD GetLocalPlayerFlags();

    CServerConnection* m_pServerConnection;
    CGameWorld* m_pGameWorld;
    CInputManager* m_pInputManager;
};

